package com.tomecode.tools.maven.settings.model;

/**
 * When Maven deploys files to the repository, it also deploys corresponding
 * checksum files. Your options are to ignore, fail, or warn on missing or
 * incorrect checksums.
 * 
 * @author Frastia Tomas
 * 
 */
public enum ChecksumPolicy {

	EMPTY(""), IGNORE("ignore"), FAIL("fail"), WARM("warm");
	private ChecksumPolicy(String name) {
		this.name = name;
	}

	private final String name;

	public final String toString() {
		return name;
	}

	public static final ChecksumPolicy parse(String check) {
		if (check == null || check.trim().length() == 0) {
			return EMPTY;
		}
		
		for (ChecksumPolicy cp : values()) {
			if (cp.toString().equals(check)) {
				return cp;
			}
		}
		return EMPTY;
	}
}
